from django.shortcuts import render
from rest_framework.response import Response
from rest_framework.views import APIView
from rest_framework.viewsets import ReadOnlyModelViewSet

from apps.food.models import Foods
from apps.index.models import SlideShow


class Banner(APIView):
    def get(self, request):
        banner = SlideShow.objects.filter(is_show=1)
        data = []
        for i in banner:
            data.append({"imgUrl": i.food_img.default_image, "caipuCode": i.food_img.id})
        res = {"status": 200, "data": data}
        return Response(res)
